﻿using System;

namespace EvoBoost.Core
{
	[Serializable]
	public class RandomSplitParameterDescription : ISplitParameterDescription
	{
		private static readonly Random random = new Random();
		
		public RandomSplitParameterDescription(int upperBoundExclusive)
		{
			if (upperBoundExclusive <= 0)
				throw new ArgumentOutOfRangeException("upperBoundExclusive", "Exclusive upper bound should be positive.");

			this.UpperBoundExclusive = upperBoundExclusive;
		}
		
		public int UpperBoundExclusive { get; private set; }
		
		public double GenerateRandom()
		{
			return random.Next(this.UpperBoundExclusive);
		}

		public double Perturb(double oldValue)
		{
			return random.Next(this.UpperBoundExclusive);
		}
	}
}
